﻿/*
* 数据库对像访问实体类
* 该类由代码自动生成
* 对数据库实体访问需要有更多的业务处理，建议新建一个类继承此类实现，以防止自动生成代码覆盖
*/
var daoBase = require('../../core/database/daoBase');
var utility = require('../../core/utilities/utilities');
class ArticleModel extends daoBase {
    get getByIdSql() {return "select *,richtext.rich_text from bus_article "+
                             " left join bas_richtext richtext on "+
                             " bus_article.article_id=richtext.data_id and richtext.bus_type=0"+
                             " where article_id=? ";}
    get updateSql() {return "update bus_article set ? where article_id=?";}
    get insertSql() {return "insert into bus_article set ?";}
    get deleteSql() {return "delete from bus_article where article_id=?";}
    ///根据主键获取一条记录
    getBykey(Sql,id) {
        return this.database.executeSql(Sql, id);
    }
    ///插入记录
    create(Sql,model){
        return this.database.executeSql(Sql, model);
    }
    ///更新记录
    update(Sql,model,id){
        return  this.database.executeSql(Sql,[model,id]);
    }
    ///删除记录
    delete(Sql,id){
        return this.database.executeSql(Sql,id);
    }
     /*
    * 设置发布状态
    */
   setPublishStatus(id,status){
       let sqlCommand = "update bus_article set article_published=? where article_id=?";
        return this.database.executeSql(sqlCommand,[status,id]);
    }
     /*
    * 设置置顶
    */
   setTop(id,status){
    let sqlCommand = "update bus_article set article_top=? where article_id=?";
     return this.database.executeSql(sqlCommand,[status,id]);
 }
}
exports = module.exports = ArticleModel;